package demo;

import java.util.Scanner;

public class Consume {
    public static void main(String[] args) {
        double apple = 8.0;
        double strawberry = 13.0;
        double mango = 20.0;
        double total=0;
        double weight ;
        double weight1 ;
        double weight2 ;
        double weight3 ;

        Scanner scanner = new Scanner(System.in);
        int consumer;
        do {
            System.out.println("请输入消费类型(0表示普通消费,1表示参加活动消费)");
            consumer = scanner.nextInt();
        } while (consumer != 0 && consumer != 1);
        if (consumer == 0) {
            do {
                 scanner = new Scanner(System.in);
                System.out.println("请输入购买苹果的斤数:");
                weight1 = scanner.nextDouble();
                System.out.println("请输入购买草莓的斤数:");
                weight2 = scanner.nextDouble();
                System.out.println("请输入购买芒果的斤数:");
                weight3 = scanner.nextDouble();
                weight = weight1 + weight2 + weight3;
            } while (weight <= 0);
             total = apple * weight1 + strawberry * weight2 + mango * weight3;
            System.out.println("您应付金额:" + total);

        } else {
            int model = -1;
            do {
                scanner = new Scanner(System.in);
                System.out.println("请输入购买苹果的斤数:");
                weight1 = scanner.nextDouble();
                System.out.println("请输入购买草莓的斤数:");
                weight2 = scanner.nextDouble();
                System.out.println("请输入购买芒果的斤数:");
                weight3 = scanner.nextDouble();
                weight = weight1 + weight2 + weight3;
            } while (weight <= 0);
            do {
                System.out.println("请输入促销模式(0表示商品打折,1表示参加满减):");
                model = scanner.nextInt();
            } while (model != 0 && model != 1);
            if (model == 0) {
                total = apple * weight1 + 0.8 * strawberry * weight2 + mango * weight3;
                System.out.println("您应付金额:" + total);
            } else if (total >= 100) {
                total = total - 10;
                System.out.println("您应付金额:" + total);
            } else {
                total = apple * weight1 + strawberry * weight2 + mango * weight3;
                System.out.println("您应付金额:" + total);
            }
        }
    }
}


